package com.zhitan.netty.enums;

public enum PileRunningStatusEnum {

    /**
     * 充电桩状态 0运行 1离线
     */
    RUNNING((byte) 0, "运行"),
    OFFLINE((byte) 1, "离线")
    ;

    private byte code;
    private String message;

    PileRunningStatusEnum(byte code, String message) {
        this.code = code;
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public void setCode(byte code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public static PileRunningStatusEnum match(int key) {
        PileRunningStatusEnum result = null;
        for (PileRunningStatusEnum s : values()) {
            if (s.getCode() == key) {
                result = s;
                break;
            }
        }
        return result;
    }

    public static PileRunningStatusEnum catchMessage(String msg) {
        PileRunningStatusEnum result = null;
        for (PileRunningStatusEnum s : values()) {
            if (s.getMessage().equals(msg)) {
                result = s;
                break;
            }
        }
        return result;
    }
}
